package org.bzjj.bean.insert;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import org.apache.log4j.Logger;
import org.bzjj.log.MyLog;
import org.bzjj.sql.OracleCon;
import org.bzjj.tool.Tools;

public class VEH_IS_INOUT_REQ {

	private static String checkpass_insert = "insert into VEH_IS_INOUT_REQ (QQXLH, XTLB, JKID, JKXLH, XMLDOC, JKLB, SESSIONID, QQZT, CJSJ, GXSJ, JYW, JKSX, XMLDOC2, BYZD1, BYZD2, BYZD3, BYZD4, BYZD5) values ('%s', '%s', '%s', %s, '%s', '%s', %s, '%s', to_date('%s', 'dd-mm-yyyy hh24:mi:ss'), to_date('%s', 'dd-mm-yyyy hh24:mi:ss'), '%s', '%s', %s, %s, %s, %s, %s, '%s');";

	private static String qqxlh_query = "select * from VEH_IS_INOUT_REQ t where qqxlh ='%s'";

	public static String getInsert(String qqxlh) {

		Connection connection = OracleCon.getDBonnect().getConnection();

		if (connection == null) {
			Logger logger = MyLog.getLog("VEH_IS_INOUT_REQ");
			logger.error("连接建立失败");
			return null;
		}
		ResultSet result = null;
		Statement stmt = null;
		String rtn = "";
		try {
			stmt = connection.createStatement();
			result = stmt.executeQuery(String.format(qqxlh_query, qqxlh));
			while (result.next()) {
				rtn += String.format(checkpass_insert,
						result.getString("QQXLH"), result.getString("XTLB"),
						result.getString("JKID"), result.getString("JKXLH"),
						result.getString("XMLDOC"), result.getString("JKLB"),
						result.getString("SESSIONID"),
						result.getString("QQZT"),
						Tools.dateFormat(result.getTimestamp("CJSJ")),
						Tools.dateFormat(result.getTimestamp("GXSJ")),
						result.getString("JYW"), result.getString("JKSX"),
						result.getString("XMLDOC2"), result.getString("BYZD1"),
						result.getString("BYZD2"), result.getString("BYZD3"),
						result.getString("BYZD4"), result.getString("BYZD5"));
			}
		} catch (SQLException e) {
			Logger logger = MyLog.getLog("VEH_IS_INOUT_REQ");
			logger.error(e.getMessage());
		}
		try {
			result.close();
			stmt.close();
			connection.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}

		return rtn;
	}

}
